Skip to content

Fix Android build for non-default NDKs with new swift-build build system, by updating ANDROID_NDK_ROOT too#280

Open
finagolfin wants to merge 1 commit into
swiftlang:mainfrom
finagolfin:patch-1
Open

Fix Android build for non-default NDKs with new swift-build build system, by updating ANDROID_NDK_ROOT too#280
finagolfin wants to merge 1 commit into
swiftlang:mainfrom
finagolfin:patch-1

Conversation

@finagolfin
Copy link
Copy Markdown
Member

@finagolfin finagolfin commented Jun 7, 2026

swiftlang/swift-testing#1745 showed that the updated NDK env var isn't being read on CI, see if it is set.

@finagolfin finagolfin requested a review from a team as a code owner June 7, 2026 11:53
alias swift='$SWIFT_EXECUTABLE_FOR_ANDROID_SDK'


log "Using NDK at $ANDROID_NDK_HOME"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakepetroules, swift-build is not using this environment variable properly on the GitHub CI, where it is correctly set to 28c before the build starts, but the internal compile shows it using NDK 27 instead. I tried setting it in $GITHUB_ENV also in the next line, but that made no difference.

This is why I pushed to not have these flaky env vars be the primary way we configure the NDK for SwiftPM, and to always notify the user that the env var is being used and with which NDK path.

Let me know if you have any idea about this bug.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift Build checks both ANDROID_NDK_ROOT and ANDROID_NDK_HOME, with the first taking precedence. Since GitHub Actions sets both, _ROOT is pointing to 27 still.

Go ahead and update GitHub actions to set both variables.

It's probably a good idea to emit a diagnostic in Swift Build if those two are set to different values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that was it, will clean this up and submit as a workaround for now.

@finagolfin finagolfin changed the title Update install-and-build-with-sdk.sh to use actual NDK location Fix Android build for non-default NDKs with new swift-build build system, by updating ANDROID_NDK_ROOT too Jun 8, 2026
…tem, by updating ANDROID_NDK_ROOT too

Also, log which NDK is being used.
@finagolfin
Copy link
Copy Markdown
Member Author

@justice-adams-apple, Android fix I'd like to get in once Jake signs off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants